<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>jsTree v.1.0 - Demo</title>
	<script type="text/javascript" src="../_lib/jquery.js"></script>
	<script type="text/javascript" src="../_lib/jquery.json-2.2.js"></script>
	<script type="text/javascript" src="../_lib/jquery.cookie.js"></script>
	<script type="text/javascript" src="../_lib/jquery.hotkeys.js"></script>
	<script type="text/javascript" src="../_lib/jquery.impromptu.js"></script>
	
	<script type="text/javascript" src="../jquery.jstree.js"></script>
	<link type="text/css" rel="stylesheet" href="../_docs/syntax/!style.css"/>
	<link type="text/css" rel="stylesheet" href="../_docs/!style.css"/>
	<script type="text/javascript" src="../_docs/syntax/!script.js"></script>
</head>
<body id="demo_body">
<div id="container">

<h1 id="dhead">jsTree v.1.0</h1>
<h1>DEMO</h1>
<h2>Creating a tree, binding events, using the instance</h2>

<div id="demo1" class="demo" style="height:100px;">

</div>

<script type="text/javascript">

justATest();

var jsonData = null;

function justATest(){
	//alert('in');

    $.getJSON('/testmvc/home/listnodes', function(data) {
		var items = [];
		jsonData = data;
		//alert(jsonData);
		//$.each(jsonData, function(key, val) {
			//$.each(val.attributes, function(key, val) {
				//alert('<li id="' + key + '">' + val + '</li>');
			//});
		//});
	})
 }


$(function() {
	$("#demo1").jstree({
		"json_data" : {
			"ajax" : {
				"url" : "/testmvc/home/listnodes",
				"data" : function(n) {
					//alert(n);
					return {
						id : n.attr ? n.attr("id") : 0
					};
				}
			}
		},
		"plugins" : [ "themes", "json_data", "ui", "crrm", "contextmenu"  ]
	});
});

	
	
	
	
		  //{
			//"url" : "/treechallenge/nodes.json",
			//"data" : function(n){ 
				//alert(n.modelMap.nodes);
				//return{n.modelMap.nodes}; 
			//},



function add_node_here(selected_node){
//alert('add node here code' + selected_node);
$("#demo1").jstree("create",-1,false,"naya folder",function(obj){alert('callback' + obj.html);},true);
//this.create_node;
}



function add_node_inside(selected_node){
alert('add node inside code' + selected_node);
$("#demo1").jstree("create","inside",false,"naya baccha folder",true);
}

  
</script>

    <body>
        <h1>This is a Spring MVC Test</h1>
        <div class="testAjaxForm">
        </div>
    </body>


</html>